<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
   
  </head>
  <body>
    <div id="app">
      <input type="text" v-model="obj.a">
      <br>
      {{obj.a}}
    </div>

    <script src="./vue.global.js"></script>
    <script>
      const { createApp } = Vue;
      const app = createApp({
        data() {
          return {
            obj: {
              a: '这是a',
              b: '这是b'
            }
          };
        },
       
        // 在config对象中定义 watch属性即可
        watch: {
          "obj.a"(val){
            console.log('obj的a属性变化了', val);
          },
          obj: {
            handler(val){
              console.log('obj改变了', val);
            },
            deep: true
          }
        }
      });
      app.mount("#app");
    </script>
  </body>
</html>
